// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Bonus Points Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 37 : TYPE_BONUSPOINTS


// Static Values

// Tables

event ObjectMain
	if object.state == 0
		foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
			CheckEqual(object[currentPlayer].state, PlayerObject_HandleMonikaTeleport)
			temp7 = checkResult
			CheckLower(object[0].value1, 20)
			temp7 &= checkResult
			if temp7 == 0				
				BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
				if checkResult == 1
					object.state = 1
					object.drawOrder = 5
					object.inkEffect = INK_ALPHA
					object.alpha = 256
					PlaySfx(SfxName[Bonus Points], 0)
					player.score += object.value1
				end if
			end if
		next
	else
		object.value0++
		if object.value0 > 105
			object.alpha -= 16
		end if
		if object.value0 == 120
			object.type = TypeName[Blank Object]
		end if
	end if
end event


event ObjectDraw
	if object.state == 1
		DrawSpriteFX(object.propertyValue, FX_INK, object.xpos, object.ypos)
	end if
end event


event ObjectStartup
	LoadSpriteSheet("Global/Display.gif")
	foreach (TypeName[Bonus Points], arrayPos0, ALL_ENTITIES)
		if options.gameMode == 2
			object[arrayPos0].type = TypeName[Blank Object]
		else
			object[arrayPos0].propertyValue &= 3
			switch object[arrayPos0].propertyValue
			case 1
				object[arrayPos0].value1 = 0x2710
				break
			case 2
				object[arrayPos0].value1 = 1000
				break
			case 3
				object[arrayPos0].value1 = 100
				break
			end switch
		end if
	next
	SpriteFrame(-16, -12, 31, 23, 225, 49)
	SpriteFrame(-16, -12, 31, 23, 225, 49)
	SpriteFrame(-16, -12, 31, 23, 225, 25)
	SpriteFrame(-16, -12, 31, 23, 225, 1)
end event

event RSDKDraw
	DrawSprite(object.propertyValue)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -12, 31, 23, 225, 49)
	SpriteFrame(-16, -12, 31, 23, 225, 49)
	SpriteFrame(-16, -12, 31, 23, 225, 25)
	SpriteFrame(-16, -12, 31, 23, 225, 1)
end event
